<?php
/**
 * Remove an inquiry
 * @package Inquiry
 */

use Fox\SalesDistribution\Sales\Inquiry;

$module  = "inquiry";
$idField = "inquiryid";
$id = Xview::instance()->val($idField);

if(empty($id))
{
	Xview::instance()->systemError();exit;
}
try {
	$object = new Inquiry($id);
	$ojectLabel = $object->reference;
}
catch (Fox\Object\Exception\NotExist $e)
{
	Xview::instance()->systemError();exit;
}
if( Xview::instance()->val("confirmation"))
{
	try {
		$object->delete();
		echo Fox\Message::Information(Msg(Fox\Msg::BUNDLE,Fox\Msg::MSG_DELETE,$ojectLabel));
		exit;
	}
	catch (Fox\Object\Exception\Save $e)
	{
		Fox\Core\Errors::pushMessage($e);
	}
}

$reload = "Refresh(\'?mod=$module&act=search\');";
$yesAction = "FoxPostForm('deleteForm','?mod=$module&act=delete&$idField=$id','$reload',null,null,null,'&confirmation=true')";
$popup = new Fox\Popup\ToConfirm("deleteForm",
								 "****".Msg(Fox\Msg::BUNDLE,Fox\Msg::MSG_DELETE_HDR,$ojectLabel)."*****",
								 "****".Msg(Fox\Msg::BUNDLE,Fox\Msg::MSG_DELETE_MSG_CONF,$ojectLabel)."*****",
								 $yesAction,null,400);
echo $popup->Display();